package cn.tedu.carehome.foundation.controller;

import cn.tedu.carehome.foundation.pojo.dto.AssessAddNewDTO;
import cn.tedu.carehome.foundation.pojo.dto.AssessUpdateDTO;
import cn.tedu.carehome.foundation.pojo.vo.AssessAdminListVO;
import cn.tedu.carehome.foundation.pojo.vo.AssessAdminStandardVO;
import cn.tedu.carehome.foundation.pojo.vo.AssessAdminUpdateStandardVO;
import cn.tedu.carehome.foundation.pojo.vo.BedAdminListVO;
import cn.tedu.carehome.foundation.service.IAssessService;
import cn.tedu.carehome.foundation.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api("能力评估测试")
@Validated
@RestController
@RequestMapping("/assess")

public class AssessController {


    @Autowired
    IAssessService assessService;

    @ApiOperation("添加记录")
    @PostMapping("/add-new")
    public JsonResult<Void> addNew(@Validated AssessAddNewDTO assessAddNewDTO) {
        log.debug("添加数据：{}", assessAddNewDTO);
        assessService.addNew(assessAddNewDTO);
        return JsonResult.ok();
    }


    @ApiOperation("能力检测数据查询")
    @GetMapping("/{id:[0-9]+}/getStandard")
    public List<AssessAdminListVO> list() {
        return assessService.list();
    }


    @ApiOperation("根据id删除数据")
    @PostMapping("/{id:[0-9]+}/deleteByid")
    public JsonResult deleteByid(@Range(min = 1, message = "id非法！") @PathVariable("id") Long id) {
        assessService.deleteByid(id);
        return JsonResult.ok();
    }

}
